<?php $this->load->view('layout/lib_chart');?>
		
		
		<?php 
			$maxheight=$row["sum_assured_death"];
			if ($row["sum_assured_disability"] > $maxheight)$maxheight = $row["sum_assured_disability"];
			if ($row["sum_assured_critical_illness"] > $maxheight)$maxheight = $row["sum_assured_critical_illness"];
			$row["policy_incepted"] = date('Y');
			$pit=$row["policy_incepted"]+$row["policy_term"];
			$policy_incepted	=	$row["policy_incepted"];
			$maxheight+=($maxheight*0.2);
			$current_year	=	date('Y');
			$min_year	= $current_year;
			if($min_year < $row['policy_incepted'])$min_year = $row['policy_incepted'];
			if($min_year < $row['year_start'])$min_year = $row['year_start'];
			if($min_year < $row['year_end'])$min_year = $row['year_end'];
		?>

		
		
		<!-- 3. Add the container -->
		<div>Existing coverage <?php echo $param?></div>
		<?php if($row["step_up_booster"] != 1):?>
			<script type="text/javascript">
				var chart1,chart2,chart3,chart4;
				$(document).ready(function() {
					chart1 = new Highcharts.Chart({
						chart: {
							renderTo: 'container1',
							defaultSeriesType: 'spline',
							inverted: true,
							width: 400,
							style: {
								//margin: '0 auto'
							}
						},
						title: {
							text: 'Protection'
						},
						subtitle: {
							//text: 'According to the Standard Atmosphere Model'
						},
						xAxis: {
							reversed: false,
							title: {
								enabled: true,
								text: 'SAD'
							},
							labels: {
								formatter: function() {
									return this.value +'';
								}
							},
							maxPadding: 0.05
						},
						yAxis: {
							title: {
								text: 'PI + t'
							},
							labels: {
								formatter: function() {
									return this.value + '';
								}
							},
							lineWidth: 2,
							min : <?php echo $policy_incepted;?>
							
						},
						legend: {
							enabled: false
						},
						tooltip: {
							formatter: function() {
								return ''+
									this.y +' / '+ this.x +'';
							}
						},
						plotOptions: {
							spline: {
								marker: {
									enable: false
								}
							}
						},
						series: [{
							name: 'Temperature',
							data: [[<?php echo $row["sum_assured_death"];?>, <?php echo $policy_incepted;?>], [<?php echo $row["sum_assured_death"];?>, <?php echo $pit;?>]]
						}]
					});
	
					chart2 = new Highcharts.Chart({
						chart: {
							renderTo: 'container2',
							defaultSeriesType: 'spline',
							inverted: true,
							width: 400,
							style: {
								//margin: '0 auto'
							}
						},
						title: {
							text: 'Protection'
						},
						subtitle: {
							//text: 'According to the Standard Atmosphere Model'
						},
						xAxis: {
							reversed: false,
							title: {
								enabled: true,
								text: 'SADI'
							},
							labels: {
								formatter: function() {
									return this.value +'';
								}
							},
							maxPadding: 0.05,
							//showLastLabel: true,
							min : 0,
							max : <?php echo 200000;?>
						},
						yAxis: {
							title: {
								text: 'PI + t'
							},
							labels: {
								formatter: function() {
									return this.value + '';
								}
							},
							lineWidth: 2,
							min : <?php echo $policy_incepted;?>
						},
						legend: {
							enabled: false
						},
						tooltip: {
							formatter: function() {
								return ''+
									this.y +' / '+ this.x +'';
							}
						},
						plotOptions: {
							spline: {
								marker: {
									enable: false
								}
							}
						},
						series: [{
							name: 'Temperature',
							data: [[<?php echo $row["sum_assured_disability"];?>, <?php echo $policy_incepted;?>], [<?php echo $row["sum_assured_disability"];?>, <?php echo $pit;?>]]
						}]
					});
	
					chart3 = new Highcharts.Chart({
						chart: {
							renderTo: 'container3',
							defaultSeriesType: 'spline',
							inverted: true,
							width: 400,
							style: {
								//margin: '0 auto'
							}
						},
						title: {
							text: 'Protection'
						},
						subtitle: {
							//text: 'According to the Standard Atmosphere Model'
						},
						xAxis: {
							reversed: false,
							title: {
								enabled: true,
								text: 'SACI',
								align: 'high'
							},
							labels: {
								formatter: function() {
									return this.value +'';
								}
							},
							maxPadding: 0.05,
							//showLastLabel: true,
							min : 0,
							max : <?php echo $maxheight;?>
						},
						yAxis: {
							title: {
								text: 'PI + t',
								align: 'high'
							},
							labels: {
								formatter: function() {
									return this.value + '';
								}
							},
							lineWidth: 2,
							min : <?php echo $policy_incepted;?>
						},
						legend: {
							enabled: false
						},
						tooltip: {
							formatter: function() {
								return ''+
									this.y +' / '+ this.x +'';
							}
						},
						plotOptions: {
							spline: {
								marker: {
									enable: false
								}
							}
						},
						series: [{
							name: 'Temperature',
							data: [[<?php echo $row["sum_assured_critical_illness"];?>, <?php echo $policy_incepted;?>], [<?php echo $row["sum_assured_critical_illness"];?>, <?php echo $pit;?>]]
						}]
					});
					
				});
					
			</script>
		<?php else:?>
			<script type="text/javascript">
				var chart1,chart2,chart3,chart4;
				$(document).ready(function() {
					chart1 = new Highcharts.Chart({
						chart: {
							renderTo: 'container1',
							defaultSeriesType: 'spline',
							inverted: true,
							width: 400,
							style: {
								//margin: '0 auto'
							}
						},
						title: {
							text: 'Protection'
						},
						subtitle: {
							//text: 'According to the Standard Atmosphere Model'
						},
						xAxis: {
							reversed: false,
							title: {
								enabled: true,
								text: 'SAD'
							},
							labels: {
								formatter: function() {
									return this.value +'';
								}
							},
							maxPadding: 0.05,
							//showLastLabel: true,
							min : 0,
							//max : <?php echo $maxheight;?>,
							plotLines: [{
				                value: <?php echo ($row["sum_assured_death"]+$row["addictional_sum_assured_death"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            },
				            {
				                value: <?php echo ($row["sum_assured_death"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            }
				            ]
						},
						yAxis: {
							title: {
								text: 'PI + t'
							},
							labels: {
								formatter: function() {
									return this.value + '';
								}
							},
							lineWidth: 2,
							//min : <?php echo $min_year;?>,
							max : <?php echo $pit;?>,
							plotLines: [{
				                value: <?php echo ($row["policy_incepted"]+$row["year_start"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            },
				            {
				                value: <?php echo ($row["policy_incepted"]+$row["year_end"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            }
				            
				            ]
						},
						legend: {
							enabled: false
						},
						tooltip: {
							formatter: function() {
								return ''+
									this.y +' / '+ this.x +'';
							}
						},
						plotOptions: {
							spline: {
								marker: {
									enable: false
								}
							}
						},
						series: [{
							name: 'Temperature',
							data: [[<?php echo $row["sum_assured_death"];?>, <?php echo $policy_incepted;?>], [<?php echo $row["sum_assured_death"];?>, <?php echo ($row["year_start"]);?>]]
						},
						{
							name: 'Temperature',
							data: [[<?php echo ($row["sum_assured_death"]+$row["addictional_sum_assured_death"]);?>, <?php echo ($row["year_start"]);?>],[<?php echo ($row["sum_assured_death"]+$row["addictional_sum_assured_death"]);?>, <?php echo ($row["year_end"]);?>]]
						},
						{
							name: 'Temperature',
							data: [[<?php echo $row["sum_assured_death"];?>, <?php echo ($row["year_end"]);?>], [<?php echo $row["sum_assured_death"];?>, <?php echo $pit;?>]]
						}
						]
					});
	
					chart2 = new Highcharts.Chart({
						chart: {
							renderTo: 'container2',
							defaultSeriesType: 'spline',
							inverted: true,
							width: 400,
							style: {
								//margin: '0 auto'
							}
						},
						title: {
							text: 'Protection'
						},
						subtitle: {
							//text: 'According to the Standard Atmosphere Model'
						},
						xAxis: {
							reversed: false,
							title: {
								enabled: true,
								text: 'SADI'
							},
							labels: {
								formatter: function() {
									return this.value +'';
								}
							},
							maxPadding: 0.05,
							//showLastLabel: true,
							min : 0,
							//max : <?php echo $maxheight;?>,
							plotLines: [{
				                value: <?php echo ($row["sum_assured_disability"]+$row["addictional_sum_assured_disability"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            },
				            {
				                value: <?php echo ($row["sum_assured_disability"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            }
				            ]
						},
						yAxis: {
							title: {
								text: 'PI + t'
							},
							labels: {
								formatter: function() {
									return this.value + '';
								}
							},
							lineWidth: 2,
							max : <?php echo $pit;?>,
							plotLines: [{
				                value: <?php echo ($row["policy_incepted"]+$row["year_start"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            },
				            {
				                value: <?php echo ($row["policy_incepted"]+$row["year_end"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            }
				            
				            ]
						},
						legend: {
							enabled: false
						},
						tooltip: {
							formatter: function() {
								return ''+
									this.y +' / '+ this.x +'';
							}
						},
						plotOptions: {
							spline: {
								marker: {
									enable: false
								}
							}
						},
						series: [{
							name: 'Temperature',
							data: [[<?php echo $row["sum_assured_disability"];?>, <?php echo $policy_incepted;?>], [<?php echo $row["sum_assured_disability"];?>, <?php echo ($row["year_start"]);?>]]
						},
						{
							name: 'Temperature',
							data: [[<?php echo ($row["sum_assured_disability"]+$row["addictional_sum_assured_disability"]);?>, <?php echo ($row["year_start"]);?>],[<?php echo ($row["sum_assured_disability"]+$row["addictional_sum_assured_disability"]);?>, <?php echo ($row["year_end"]);?>]]
						},
						{
							name: 'Temperature',
							data: [[<?php echo $row["sum_assured_disability"];?>, <?php echo ($row["year_end"]);?>], [<?php echo $row["sum_assured_disability"];?>, <?php echo $pit;?>]]
						}
						]
					});
	
					chart3 = new Highcharts.Chart({
						chart: {
							renderTo: 'container3',
							defaultSeriesType: 'spline',
							inverted: true,
							width: 400,
							style: {
								//margin: '0 auto'
							}
						},
						title: {
							text: 'Protection'
						},
						subtitle: {
							//text: 'According to the Standard Atmosphere Model'
						},
						xAxis: {
							reversed: false,
							title: {
								enabled: true,
								text: 'SACI',
								align: 'high'
							},
							labels: {
								formatter: function() {
									return this.value +'';
								}
							},
							maxPadding: 0.05,
							//showLastLabel: true,
							min : 0,
							//max : <?php echo $maxheight;?>,
							plotLines: [{
				                value: <?php echo ($row["sum_assured_critical_illness"]+$row["addictional_sum_assured_critical"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            },
				            {
				                value: <?php echo ($row["sum_assured_critical_illness"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            }
				            ]
						},
						yAxis: {
							title: {
								text: 'PI + t',
								align: 'high'
							},
							labels: {
								formatter: function() {
									return this.value + '';
								}
							},
							lineWidth: 2,
							max : <?php echo $pit;?>,
							plotLines: [{
				                value: <?php echo ($row["policy_incepted"]+$row["year_start"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            },
				            {
				                value: <?php echo ($row["policy_incepted"]+$row["year_end"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            }
				            
				            ]
						},
						legend: {
							enabled: false
						},
						tooltip: {
							formatter: function() {
								return ''+
									this.y +' / '+ this.x +'';
							}
						},
						plotOptions: {
							spline: {
								marker: {
									enable: false
								}
							}
						},
						series: [{
							name: 'Temperature',
							data: [[<?php echo $row["sum_assured_critical_illness"];?>, <?php echo $policy_incepted;?>], [<?php echo $row["sum_assured_critical_illness"];?>, <?php echo ($row["year_start"]);?>]]
						},
						{
							name: 'Temperature',
							data: [[<?php echo ($row["sum_assured_critical_illness"]+$row["addictional_sum_assured_critical"]);?>, <?php echo ($row["year_start"]);?>],[<?php echo ($row["sum_assured_critical_illness"]+$row["addictional_sum_assured_critical"]);?>, <?php echo ($row["year_end"]);?>]]
						},
						{
							name: 'Temperature',
							data: [[<?php echo $row["sum_assured_critical_illness"];?>, <?php echo ($row["year_end"]);?>], [<?php echo $row["sum_assured_critical_illness"];?>, <?php echo $pit;?>]]
						}
						]
					});
					
				});
					
			</script>
		<?php endif;?>
		
		<?php if($row["consider_cash_value_retirement"] == 1):?>
			<script type="text/javascript">
				var chart4;
				$(document).ready(function() {
					chart4 = new Highcharts.Chart({
						chart: {
							renderTo: 'chart4',
							defaultSeriesType: 'spline',
							inverted: true,
							width: 400,
							style: {
								//margin: '0 auto'
							}
						},
						title: {
							text: 'Retirement'
						},
						subtitle: {
							//text: 'According to the Standard Atmosphere Model'
						},
						xAxis: {
							reversed: false,
							title: {
								enabled: true,
								text: 'MV',
								align: 'high'
							},
							labels: {
								formatter: function() {
									return this.value +'';
								}
							},
							maxPadding: 0.05,
							//showLastLabel: true,
							min : 0,
							plotLines: [{
				                value: <?php echo $row["cva_retirement"];?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            }]
							//gridLineWidth: 1
						},
						yAxis: {
							title: {
								text: 'MY',
								//align: 'slow',
								//margin-left : 80
							},
							labels: {
								formatter: function() {
									return this.value + '';
								}
							},
							lineWidth: 2,
							gridLineWidth: 0,
							plotLines: [{
				                value: <?php echo $row["retirement_age"];?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            }]
						},
						legend: {
							enabled: false
						},
						tooltip: {
							formatter: function() {
								return ''+
									this.y +' / '+ this.x +'';
							}
						},
						plotOptions: {
							spline: {
								marker: {
									enable: false
								}
							}
						},
						series: [{
							name: 'Temperature',
							data: [[<?php echo $row["cva_retirement"];?>, <?php echo $row["retirement_age"];?>],[<?php echo $row["cva_retirement"];?>,<?php echo $row["retirement_age"]+10;?>]]
						}]
					});
				});
			</script>
		<?php endif;?>
		
		<table>
			<?php if($row["step_up_booster"] != 1):?>
			
			
			<tr>
				<td><div id="container1" style="width: 400px; height: 400px; margin: 0 auto"></div></td>
				<td><div id="container2" style="width: 400px; height: 400px; margin: 0 auto"></div></td>
				
			</tr>
			<?php else:?>
			
			<tr>
				<td><div id="container1" style="width: 400px; height: 400px; margin: 0 auto"></div></td>
				<td><div id="container2" style="width: 400px; height: 400px; margin: 0 auto"></div></td>
				
			</tr>
			<?php endif;?>
			
			<tr>
			<td><div id="container3" style="width: 400px; height: 400px; margin: 0 auto"></div></td>
			<?php
			if($row["consider_cash_value_retirement"] == 1):
			?>
				<td>
					<div id="chart4" style="width: 400px; height: 400px; margin: 0 auto"></div>
				</td>
			<?php
			endif;
			?>
			</tr>
			
		</table>
		
